<?php

namespace console\controllers;

use Yii;

class DeliveryController extends BaseController
{
	
    public function actionEsimport($all = 0)
    {
    	if ($is_all = 1) {

    	} else {
    		$end_time = date('Y-m-d') . ' 00:00:00';
    		$start_time = date('Y-m-d H:i:s', (strtotime($end_time) - 86400));
    	}
        $sql = "SELECT * FROM ebtBillHeader WHERE OperateTime>='{start_time}' AND OperateTime<'{$end_time}'";
        $rows = Yii::$app->db_yisu->createCommand($sql)->queryAll();
        if (!empty($rows)) {
        	$data = [];
            foreach ($rows as $k => $v) {
                $reciver_sql = "SELECT * FROM sysOrganization WHERE Id='{$v['DestId']}'";
                $reciver = Yii::$app->db_yisu->createCommand($reciver_sql)->queryOne();
            	$data[] = [
            		'source_id' => $v['Id'],
            		'code' => $v['Code'],
            		'amount' => $v['RealQtyPcs'],
            		'send_at' => strtotime(substr($v['AddTime'], 0, 10)),
            	];
            }
        }
    }
}